package com.hc.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;

@WebFilter("/*")//鐢ㄦ敞瑙ｆ浛浠eb.xml涓殑閰嶇疆
public class MyFilter implements Filter {
	//杩囨护鍣ㄩ殢鐫�鏈嶅姟鍣ㄥ紑鍚嚭鐢� 鏈嶅姟鍣ㄥ叧闂攢姣�
	
	//涓枃缂栫爜杩囨护鍣�
	@Override //鏍稿績澶勭悊鏂规硶
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		
		//瑙ｅ喅璇锋眰鍙傛暟鐨勪腑鏂囦贡鐮�
		request.setCharacterEncoding("utf-8");
		//瑙ｅ喅鍝嶅簲涓枃涔辩爜
		response.setContentType("text/html;charset=utf-8");
		//杩囨护鍣ㄦ斁琛�
		chain.doFilter(request, response);
		
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
		// TODO Auto-generated method stub
		
	}

	

}
